﻿Imports System.Data.SqlClient
Public Class frm_themtk

    Private Sub cmd_them_Click(sender As Object, e As EventArgs) Handles cmd_them.Click
        Dim cmd As New SqlCommand("sp_themnguoidung", conn)
        cmd.CommandType = CommandType.StoredProcedure

        cmd.Parameters.AddWithValue("@tendangnhap", txt_tendn.Text)
        cmd.Parameters.AddWithValue("@machucvu", txt_macv.Text)
        cmd.Parameters.AddWithValue("@tennguoidung", txt_tennd.Text)
        cmd.Parameters.AddWithValue("@matkhau", txt_matkhau.Text)

        Dim i As Integer = cmd.ExecuteNonQuery

        If i > 0 Then
            MsgBox("Chúc mừng đã Thêm tài khoản thành công")
            cmd_huybo_Click(sender, e)
        Else
            MsgBox("mã chức vụ không đúng thêm tài khoản thất bại")
        End If
    End Sub

    Private Sub cmd_huybo_Click(sender As Object, e As EventArgs) Handles cmd_huybo.Click
        For Each k As Control In Me.Controls
            If TypeOf k Is TextBox Then
                k.Text = ""
                txt_tendn.Focus()
            End If
        Next
    End Sub
End Class